package com.world.lzh.controller;/**
 * @Author liuzihong
 * @Date 2022/4/30 9:29
 * @Version 1.0
 */

import com.world.lzh.entity.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Date;

/**
 * @Author lzh
 * @Date 2022/4/30 - 9:29
 * @Description
 * @Version 1.0.0
 **/
@Controller
@RequestMapping("/index")
public class IndexController {

    @RequestMapping("/thymeleaf")
    public String testThymeleaf(ModelMap modelMap) {
        modelMap.addAttribute("msg", "Hello lzh!welcome to learn thymeleaf!");
        return "index";
    }

    @RequestMapping("/user")
    public String getUser(ModelMap modelMap) {
        User user = new User();
        user.setAge(18);
        user.setBirthday(new Date());
        user.setName("张三");
        user.setPhone("18856781234");
        modelMap.addAttribute("user",user);
        return "user";
    }
}
